/*
 * Created on 14.02.2005
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package ro.qi.framework.sys.security;

import java.util.Calendar;

import ro.qi.framework.sys.debug.Logger;

/**
 * @author vlad lepadatu
 * 
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class SecurityManager {

	private static SecurityManager instance = null;
	
	private SecurityManager() {
	}

	public static synchronized SecurityManager getInstance() {
		if( instance == null ) {
			instance = new SecurityManager();
			instance.init();
		}
		return instance;
	}

	public void stop() {
		Logger.debug(this, "Stoping Security Manager.");
		instance = null;
	}

	public static boolean isStarted() {
		return instance != null;
	}

	private void init() {
		Logger.info(this, "Initializing security ... ");
	}
	
	public void initCache() {
		
	}

	public void refreshCache() {
		Logger.info(this, "Start caching the database configuration");
		Calendar cal1 = Calendar.getInstance();


		Calendar cal2 = Calendar.getInstance();
		double diff = cal2.getTime().getTime() - cal1.getTime().getTime();

		Logger.info(this, "End caching the database configuration (" + diff + " ms)");
		Logger.info(this, "Readed:");
//		Logger.info(this, "\t" + sites.size() + " site(s)");
//		Logger.info(this, "\t" + interfaces.size() + " interface(s)");
//		Logger.info(this, "\t" + interfaceUrls.size() + " interface url(s)");
//		Logger.info(this, "\t" + interfaceLocales.size() + " interface locale(s)");
//		Logger.info(this, "\t" + nodes.size() + " node(s)");
	}

	public String getCache() {
		return "locales cache";
	}

}
